import type { GlobConfig } from '@/types/setting';

const getAppEnvConfig = () => {
  const gloablConfig = import.meta.env;
  return gloablConfig;
};
export const useGlobSetting = (): Readonly<GlobConfig> => {
  const {
    VITE_GLOB_APP_TITLE,
    VITE_GLOB_API_URL_PREFIX,
    VITE_PUBLIC_PATH,
    VITE_LOGIN_PATH,
    VITE_DEFAULT_PRIMARY,
  } = getAppEnvConfig();

  // Take global configuration
  const glob: Readonly<GlobConfig> = {
    title: VITE_GLOB_APP_TITLE,
    apiUrl: VITE_GLOB_API_URL_PREFIX,
    path: VITE_PUBLIC_PATH,
    loginPath: VITE_LOGIN_PATH,
    primary: VITE_DEFAULT_PRIMARY,
  };
  return glob as Readonly<GlobConfig>;
};
